package game.graphics
{
	import engine.asset.*;
	import engine.core.*;
	
	public class RxGigaTextureInfo
	{
		private var m_prefixes:Vector.<String>;
		private var m_extensions:Vector.<String>;
		private var m_gridWidth:uint;
		private var m_gridHeight:uint;
		private var m_numSlices:uint;
		private var m_numDigits:uint;
		private var m_sliceWidth:uint;
		private var m_sliceHeight:uint;
		private var m_totalWidth:uint;
		private var m_totalHeight:uint;
		private var m_path:String;
		private var m_callback:Function;
		public static const TEXTURE_TYPE_COLOR:uint = 0;
		public static const TEXTURE_TYPE_DEPTH:uint = 1;
		public static const NUM_TEXTURE_TYPES:uint = 2;
		
		public function RxGigaTextureInfo()
		{
			this.m_prefixes = new Vector.<String>(NUM_TEXTURE_TYPES, true);
			this.m_extensions = new Vector.<String>(NUM_TEXTURE_TYPES, true);
			this.m_gridWidth = 0;
			this.m_gridHeight = 0;
			this.m_numSlices = 0;
			this.m_numDigits = 0;
			this.m_sliceWidth = 0;
			this.m_sliceHeight = 0;
			this.m_totalWidth = 0;
			this.m_totalHeight = 0;
			this.m_path = "";
			this.m_callback = null;
		}
		
		public function GetSliceIndex(param1:uint, param2:uint) : uint
		{
			return param2 * this.m_gridWidth + param1;
		}
		
		public function GetPrefix(param1:uint) : String
		{
			return this.m_prefixes[param1];
		}
		
		public function GetExtension(param1:uint) : String
		{
			return this.m_extensions[param1];
		}
		
		public function GetGridWidth() : uint
		{
			return this.m_gridWidth;
		}
		
		public function GetGridHeight() : uint
		{
			return this.m_gridHeight;
		}
		
		public function GetNumSlices() : uint
		{
			return this.m_numSlices;
		}
		
		public function GetSliceWidth() : uint
		{
			return this.m_sliceWidth;
		}
		
		public function GetSliceHeight() : uint
		{
			return this.m_sliceHeight;
		}
		
		public function GetTotalWidth() : uint
		{
			return this.m_totalWidth;
		}
		
		public function GetTotalHeight() : uint
		{
			return this.m_totalHeight;
		}
		
		public function GetPath() : String
		{
			return this.m_path;
		}
		
		public function GetSliceURLs(param1:uint) : Vector.<String>
		{
			var _loc_2:uint = 0;
			var _loc_7:String = null;
			var _loc_3:* = new String();
			_loc_2 = 0;
			while (_loc_2 < this.m_numDigits)
			{
				
				_loc_3 = _loc_3.concat("0");
				_loc_2 = _loc_2 + 1;
			}
			var _loc_4:* = String(param1);
			var _loc_5:* = String(param1).length;
			if (String(param1).length < this.m_numDigits)
			{
				_loc_7 = _loc_3.slice(0, this.m_numDigits - _loc_5);
				_loc_4 = _loc_7.concat(_loc_4);
			}
			var _loc_6:* = new Vector.<String>(NUM_TEXTURE_TYPES, true);
			_loc_2 = 0;
			while (_loc_2 < NUM_TEXTURE_TYPES)
			{
				
				_loc_6[_loc_2] = new String(this.m_path + this.m_prefixes[_loc_2] + _loc_4 + "." + this.m_extensions[_loc_2]);
				_loc_2 = _loc_2 + 1;
			}
			return _loc_6;
		}
		
		public function ParseFromXML(param1:String, param2:XMLList) : Boolean
		{
			if (param2 == null || param2.length() == 0)
			{
				return false;
			}
			this.m_prefixes[TEXTURE_TYPE_COLOR] = param2.@prefixColor;
			this.m_extensions[TEXTURE_TYPE_COLOR] = param2.@extColor;
			this.m_prefixes[TEXTURE_TYPE_DEPTH] = param2.@prefixDepth;
			this.m_extensions[TEXTURE_TYPE_DEPTH] = param2.@extDepth;
			this.m_gridWidth = uint(param2.@gridWidth);
			this.m_gridHeight = uint(param2.@gridHeight);
			this.m_numSlices = this.m_gridWidth * this.m_gridHeight;
			var _loc_3:* = Math.log(this.m_numSlices) / Math.LN10;
			this.m_numDigits = uint(Math.floor(_loc_3)) + 1;
			this.m_sliceWidth = uint(param2.@sliceWidth);
			this.m_sliceHeight = uint(param2.@sliceHeight);
			this.m_totalWidth = this.m_gridWidth * this.m_sliceWidth;
			this.m_totalHeight = this.m_gridHeight * this.m_sliceHeight;
			this.m_path = RxUtilities.MergePath(param1, "");
			return true;
		}
	}
}